import request from "@/utils/request";
import {OrderPageResult, OrderQuery, OrderRefundVo} from "@/api/order/types";
import {AxiosPromise} from "axios";

const baseUri = "/mv1/api/order";

/**
 * 获取角色分页数据
 *
 * @param queryParams
 */
export function getOrderList(
  queryParams?: OrderQuery
): AxiosPromise<OrderPageResult> {
  return request({
    url: baseUri + "/",
    method: "get",
    params: queryParams,
  });
}

/**
 * 订单详情
 * @param id
 */
export function orderDetail(id: number) {
  return request({
    url: baseUri + "/detail/" + id,
    method: "get",
    // params: data || {}
  });
}

/**
 * 退款
 * @param id
 */
export function refundOrder(id: number | string, data: OrderRefundVo) {
  // data['type'] = type;
  return request({
    url: baseUri + "/refund/" + id,
    method: "post",
    params: data
  });
}

/**
 * 备注
 * @param id
 */
export function editNote(id: number | string, note: string) {
  return request({
    url: baseUri + "/edit_note/" + id,
    method: "put",
    params: {
      note: note
    }
  });
}

/**
 * 删除订单
 *
 * @param ids
 */
export function deleteOrder(ids: string | number) {
  return request({
    url: baseUri + "/" + ids,
    method: "delete",
  });
}
